var totalPage =2;//一共多少页数据
	var pageSize =6;//每页显示10条数据
	var currentPage =1;//当前第几页数据，默认为1
	var isLoading = false;//是否正在加载更多数据//
$(function(){
    $('#movieTime').datetimepicker({
        minView:'year',
	    lang:'ch',
	    timepicker:true,
	   // format:'Y-m-d H:i:s',
	    format:'Y-m-d H:i:s',
	    allowBlank: true,
	    
	});  
    $('#search-startTime').datetimepicker({
        minView:'year',
	    lang:'ch',
	    timepicker:true,
	   // format:'Y-m-d H:i:s',
	    format:'Y-m-d H:i:00',
	    allowBlank: true,
	    
	}); 
    $('#search-endTime').datetimepicker({
        minView:'year',
	    lang:'ch',
	    timepicker:true,
	   // format:'Y-m-d H:i:s',
	    format:'Y-m-d H:i:00',
	    allowBlank: true,
	    
	});
	$('#movieCategoryId').select2({minimumResultsForSearch : 'Infinity',theme : 'bootstrap'});
	$('#isHotSearch').select2({minimumResultsForSearch : 'Infinity',theme : 'bootstrap'});
	$('#hallId').select2({minimumResultsForSearch : 'Infinity',theme : 'bootstrap'});
	$('#isHotName').select2({minimumResultsForSearch : 'Infinity',theme : 'bootstrap'});
	$('#isSell').select2({minimumResultsForSearch : 'Infinity',theme : 'bootstrap'});
 
	
	selectAllMovieInfo(1);
	function selectAllMovieInfo(pageNum){
		 var p ={};
         p.pageSize = pageSize;
         p.pageNum = pageNum;
		  $('#movie-table').empty();
		  $('#movie-table').append('<tr><td></td><td  hidden="true">主键号</td> <td>序号</td><td>电影名称</td><td>上映时间</td><td>价格(元)</td><td>是否热门</td><td>是否预售期</td><td>影厅</td><td>影片</td></tr>');
	$.ajax({
		  type:"POST",
		  url:"/movie.front/movieInfo/getSysAllMovieInfoList",
		  data:JSON.stringify(p),
		  dataType:"json",
		  contentType:"application/json",
		  success:function(data){
           array =  data.result.list;
           var url='http://localhost:8080/';
           for(var i=0;i<array.length;i++){
        	   var html = '' ;
        	   var movieTime = transfer(array[i].movieTime);
        	   var moviePicture = array[i].moviePicture;
        	   var hallName = array[i].hallName;
        	   if((moviePicture==""||moviePicture==undefined)){
        		   if(array[i].isHot==1){
        			
             		  html = html+'<tr><td><input type="checkbox" id="'+array[i].id+'"></td><td  hidden="true">'+array[i].id+'</td><td>'+(i+1)+'</td><td>'+array[i].movieName+'</td><td>'+movieTime+'</td><td>'+array[i].moviePrice+'</td><td>是</td><td>'+ array[i].isSell+'</td><td>'+array[i].hallName+'</td><td></td></tr>';  
             	  }else{
             		  html = html+'<tr><td><input type="checkbox" id="'+array[i].id+'"></td><td  hidden="true">'+array[i].id+'</td><td>'+(i+1)+'</td><td>'+array[i].movieName+'</td><td>'+movieTime+'</td><td>'+array[i].moviePrice+'</td><td>否</td><td>'+array[i].isSell+'</td><td>'+array[i].hallName+'</td><td></td></tr>';
             	 
        		   }
        	   }
        	    
        	     else{
        	      if(array[i].isHot==1){
        		  html = html+'<tr><td><input type="checkbox" id="'+array[i].id+'"></td><td  hidden="true">'+array[i].id+'</td><td>'+(i+1)+'</td><td>'+array[i].movieName+'</td><td>'+movieTime+'</td><td>'+array[i].moviePrice+'</td><td>是</td><td>'+array[i].isSell+'</td><td>'+array[i].hallName+'</td><td><img style="width:60px;height:80px" src='+url+array[i].moviePicture+'></td></tr>';  
        	     }else{
        		  html = html+'<tr><td><input type="checkbox" id="'+array[i].id+'"></td><td  hidden="true">'+array[i].id+'</td><td>'+(i+1)+'</td><td>'+array[i].movieName+'</td><td>'+movieTime+'</td><td>'+array[i].moviePrice+'</td><td>否</td><td>'+array[i].isSell+'</td><td>'+array[i].hallName+'</td><td><img style="width:60px;height:80px" src='+url+array[i].moviePicture+'></td></tr>';
        	     }
        	   }
           	    $('#movie-table').append(html); 
           }
           $('#paginator').empty();
           var totalPages = data.result.pages;
        	   var pageHtml = '<ul>';
        	   pageHtml =pageHtml+'<li class="m-pagination-page"><a herf="javascript:void(0);" id="firstPage" onclick="firstPagesquery(1)"> 首页 </a></li>';
        	   for(var i=0;i<totalPages;i++){
        		  pageHtml = pageHtml+'<li class="m-pagination-page"><a herf="javascript:void(0);" onclick="currentPagesquery('+(i+1)+')" id='+(i+1)+'>'+(i+1)+'</a></li>'; 
        	   }
        	   pageHtml =pageHtml+'<li class="m-pagination-page"><a herf="javascript:void(0);" id="endPage" onclick="endPagequery('+totalPages+')">尾页</a></li>';
        	   pageHtml =pageHtml+'</ul>';
        	   $('#paginator').append(pageHtml);
          }
	
	   });
		
	}

	
	$('#btn-search').click(function(){
		var movieName = $('#search-movieName')[0].value;
	    var isSell =$('#isHotSearch')[0].value;
	    var startTime = $('#search-startTime')[0].value;
	    var endTime = $('#search-endTime')[0].value;
	    querySearchMovieInfo(1,movieName,isSell,startTime,endTime);
	});
	function querySearchMovieInfo(pageNum,movieName,isSell,startTime,endTime){
		var p={};
		p.pageSize = pageSize;
		p.pageNum = pageNum;
		p.movieName = movieName;
		p.startTime = startTime;
		p.endTime = endTime;
		p.isSell = isSell;
		  $('#movie-table').empty();
		  $('#movie-table').append('<tr><td></td><td  hidden="true">主键号</td> <td>序号</td><td>电影名称</td><td>上映时间</td><td>价格(元)</td><td>是否热门</td><td>是否预售</td><td>影厅</td><td>影片</td></tr>');
	$.ajax({
		  type:"POST",
		  url:"/movie.front/movieInfo/getSysAllMovieInfoList",
		  data:JSON.stringify(p),
		  dataType:"json",
		  contentType:"application/json",
		  success:function(data){
           array =  data.result.list;
           var url='http://localhost:8080/';
           for(var i=0;i<array.length;i++){
        	   var html = '' ;
        	   var movieTime = transfer(array[i].movieTime);
        	   var moviePicture = array[i].moviePicture;
        	   if(moviePicture==""||moviePicture==undefined){
        		   if(array[i].isHot==1) {
             		  html = html+'<tr><td><input type="checkbox" id="'+array[i].id+'"></td><td  hidden="true">'+array[i].id+'</td><td>'+(i+1)+'</td><td>'+array[i].movieName+'</td><td>'+movieTime+'</td><td>'+array[i].moviePrice+'</td><td>是</td><td>'+array[i].isSell+'</td><td>'+arry[i].hallName+'</td><td></td></tr>';  
             	  }else{
             		  html = html+'<tr><td><input type="checkbox" id="'+array[i].id+'"></td><td  hidden="true">'+array[i].id+'</td><td>'+(i+1)+'</td><td>'+array[i].movieName+'</td><td>'+movieTime+'</td><td>'+array[i].moviePrice+'</td><td>否</td><td>'+array[i].isSell+'</td><td>'+array[i].hallName+'</td><td></td></tr>';
             	  }
        	   }else{
        	      if(array[i].isHot==1){
        		  html = html+'<tr><td><input type="checkbox" id="'+array[i].id+'"></td><td  hidden="true">'+array[i].id+'</td><td>'+(i+1)+'</td><td>'+array[i].movieName+'</td><td>'+movieTime+'</td><td>'+array[i].moviePrice+'</td><td>是</td><td>'+array[i].isSell+'</td><td>'+array[i].hallName+'</td><td><img style="width:60px;height:80px" src='+url+array[i].moviePicture+'></td></tr>';  
        	     }else{
        		  html = html+'<tr><td><input type="checkbox" id="'+array[i].id+'"></td><td  hidden="true">'+array[i].id+'</td><td>'+(i+1)+'</td><td>'+array[i].movieName+'</td><td>'+movieTime+'</td><td>'+array[i].moviePrice+'</td><td>否</td><td>'+array[i].isSell +'</td><td>'+array[i].hallName+'</td><td><img style="width:60px;height:80px" src='+url+array[i].moviePicture+'></td></tr>';
        	     }
        	   }
           	    $('#movie-table').append(html); 
           }
           $('#paginator').empty();
           var totalPages = data.result.pages;
        	   var pageHtml = '<ul>';
        	   pageHtml =pageHtml+'<li class="m-pagination-page"><a herf="javascript:void(0);" id="firstPage" onclick="firstPagesquery(1)"> 首页 </a></li>';
        	   for(var i=0;i<totalPages;i++){
        		  pageHtml = pageHtml+'<li class="m-pagination-page"><a herf="javascript:void(0);" onclick="currentPagesqueryParam('+((i+1),p)+')" id='+(i+1)+'>'+(i+1)+'</a></li>'; 
        	   }
        	   pageHtml =pageHtml+'<li class="m-pagination-page"><a herf="javascript:void(0);" id="endPage" onclick="endPagequery('+totalPages+')">尾页</a></li>';
        	   pageHtml =pageHtml+'</ul>';
        	   $('#paginator').append(pageHtml);
          }
	
	   });
	}
	
	
	//重置
	$('#btn-reset').click(function(){
		$('#search-movieName').val("");
		$("#isHotSearch").val(null).trigger('change');
		 $('#search-endTime').val("");
		 $('#search-startTime').val("");
	
	})

   $('#btn-insert').click(function(){
	   emptyMyDialog();
	  $('#myModal').modal('show');
     });
	selectAllHall();
	//影厅
	function selectAllHall(){
		var p={p:null}
		$.ajax({
			  type:"POST",
			  url:"/movie.front/movieInfo/getSysfindAllHall",
			  data:JSON.stringify(p),
			  dataType:"json",
			  contentType:"application/json",
			  success:function(data){
					$('#hallId').select2({
						theme : 'bootstrap',
						data : data.result
					});
	   
			   
	          }
		
		   });
	};
	selectAllCategory();
	//种类
	function selectAllCategory(){
		var p={p:null}
		$.ajax({
			  type:"POST",
			  url:"/movie.front/movieInfo/findAllCategory",
			  data:JSON.stringify(p),
			  dataType:"json",
			  contentType:"application/json",
			  success:function(data){
	     	$('#movieCategoryId').select2({
				theme : 'bootstrap',
				data : data.result
			});
	          }
		
		   });
	}
	//清空对话框内容
	function emptyMyDialog(){
		$('#movieName')[0].value='';
		$('#movieTime')[0].value='';
		$('#moviePrice')[0].value='';
	//	$('#moviePicture')[0].value='';
		$('#movieIntro')[0].value='';
		$('#id')[0].value='';
		$("#hallId").val(null).trigger('change');
		$("#movieCategoryId").val(null).trigger('change');
		$("#isHot").val(null).trigger('change');
		$("#isSell").val(null).trigger('change');
		
	}
	
	//保存图片
	$('#btn-save-movie').click(function(){
		/*debugger;*/
	var movieName =	$('#movieName')[0].value;
	var movieTime =	$('#movieTime')[0].value;
	var moviePrice =$('#moviePrice')[0].value;
	var movieIntro =	$('#movieIntro')[0].value;
	var hallId =	$("#hallId")[0].value;
	var movieCategoryId =	$("#movieCategoryId")[0].value;
	var ishot =	$('#isHotName')[0].value;
	var isSell = $('#isSell')[0].value;
	var id = $('#id')[0].value;
	if(id==null || id==""){
	var p={movieName:movieName,movieTime:movieTime,moviePrice:moviePrice,movieIntro:movieIntro,hallId:hallId,movieCategoryId:movieCategoryId,isHot:ishot,isSell:isSell}
	$.ajax({
		  type:"POST",
		  url:"/movie.front/movieInfo/addMovieInfo",
		  data:JSON.stringify(p),
		  dataType:"json",
		  contentType:"application/json",
		  success:function(data){
			 if(data.successcode>0){
			  $('#myModal').modal('hide');
			/*  var d={d:null}*/
           	selectAllMovieInfo(1);
			  emptyMyDialog();
			 }else{
				 alert("网络连接失败");
			 }
        }
	
	   });
	}else{
		var p={id:id,movieName:movieName,movieTime:movieTime,moviePrice:moviePrice,movieIntro:movieIntro,hallId:hallId,movieCategoryId:movieCategoryId,isHot:ishot,isSell:isSell}
		$.ajax({
			  type:"POST",
			  url:"/movie.front/movieInfo/updateMovieInfo",
			  data:JSON.stringify(p),
			  dataType:"json",
			  contentType:"application/json",
			  success:function(data){
				//  alert(data.successcode);
				  if(data.successcode!=null){
					  $('#myModal').modal('hide');
						//刷新表格
			            	selectAllMovieInfo(1);					  
				  }
				  if(data.errorcode!=null){
		            //	alert(data.errorcode);
		             alert("网络连接失败");  
				  }

			   
			  }
		
		   });
	}
	
	});
	
	//修改电影信息
	$('#btn-update-movie').click(function(){
		var flag=0;
		var id =0;
		var array = $(("input[type='checkbox']"));
		for(var i=0;i<array.length;i++){
		  console.info(array[i].id);
		  if($('#'+array[i].id).is(':checked')){
			var id = array[i].id;
		      flag++;
		      if(flag>1){
		    	  alert("对不起，只能选择单行");
		    	return false;
		      }else{
		    	  id=array[i].id;
		      }
		
		  }
	   
		}
		  if(flag==1){
			  emptyMyDialog();
			  $('#myModal').modal('show');
			  var id = {id:id};
			  getByIdMovieInfo(id);
		     }
	
	});
	
	function getByIdMovieInfo(p){
		$.ajax({
			  type:"POST",
			  url:"/movie.front/movieInfo/getMovieInfoById",
			  data:JSON.stringify(p),
			  dataType:"json",
			  contentType:"application/json",
			  success:function(data){
				   	$('#movieName')[0].value=data.result.movieName;
					$('#movieTime')[0].value=transfer(data.result.movieTime);
					$('#moviePrice')[0].value=data.result.moviePrice;
					$('#movieIntro')[0].value=data.result.movieIntro;
				    $("#hallId").val(data.result.hallId).trigger('change');
					$("#movieCategoryId").val(data.result.movieCategoryId).trigger('change');
					$("#isHotName").val(data.result.isHot).trigger('change');
					$("#isSell").val(data.result.isSell).trigger('change');
			        $('#id')[0].value=data.result.id;
			  }
		
		   });
	}
	
	
	//删除电影信息
	$('#btn-remove-movie').click(function(){
		var flag=0;
		var id =0;
		var array = $(("input[type='checkbox']"));
		for(var i=0;i<array.length;i++){
		  console.info(array[i].id);
		  if($('#'+array[i].id).is(':checked')){
			var id = array[i].id;
		      flag++;
		      if(flag>1){
		    	  alert("对不起，只能选择单行");
		    	return false;
		      }else{
		    	  id=array[i].id;
		      }
		
		  }
	   
		}
		  if(flag==1){
			  var id = {id:id};
			  deleteMovieById(id);
		     }
		
	});
	
	function deleteMovieById(id){
		$.ajax({
			  type:"POST",
			  url:"/movie.front/movieInfo/deleteMovieInfoById",
			  data:JSON.stringify(id),
			  dataType:"json",
			  contentType:"application/json",
			  success:function(data){
				  if(data.successcode!=null){
					  $('#myModal').modal('hide');
						//刷新表格
			            	selectAllMovieInfo(1);	
			            	alert("删除成功");
				  }
				  if(data.errorcode!=null){
		             alert("网络连接失败");  
				  }
			  }
		
		   });
	}
	
	//上传影片的信息
	$('#btn-upload-picture').click(function(){
		var flag=0;
		var id =0;
		var array = $(("input[type='checkbox']"));
		for(var i=0;i<array.length;i++){
		  console.info(array[i].id);
		  if($('#'+array[i].id).is(':checked')){
			var id = array[i].id;
		      flag++;
		      if(flag>1){
		    	  alert("对不起，只能选择单行");
		    	return false;
		      }else{
		    	  id=array[i].id;
		      }
		
		  }
	   
		}
		  if(flag==1){
			  $('#uploadFile').val("");
			  $('#myPictureModal').modal('show');
			  $('#idFile')[0].value=id;
			 
		     }
		
	});
	
	$('#btn-save-picture').click(function(){
		var id = $('#idFile')[0].value;
		
		uploadMoviePicture(id);
	});
	
	function uploadMoviePicture(id){
		   $.ajaxFileUpload({
                   url: '/movie.front/movieInfo/uploadMovieById', //用于文件上传的服务器端请求地址
                   type: 'post',
                   data:{id:id}, //此参数非常严谨，写错一个引号都不行
                   secureuri: false, //一般设置为false
                   fileElementId: 'uploadFile', //文件上传空间的id属性  <input type="file" id="file" name="file" />
                   dataType: 'JSON',//返回值类型 一般设置为json
                   success: function (data,status){  //服务器成功响应处理函数
                	   if(status=='success'){
                           data = jQuery.parseJSON(jQuery(data).text());
                		   if(data.successcode>0){
                			   alert("上传成功");
                			   $('#myPictureModal').modal('hide');
                				selectAllMovieInfo(1);
                		   }else{
                			   alert("上传失败");
                		   }
                	   }
             
                   },
                   error: function (data)//服务器响应失败处理函数
                   {
                       alert("网络连接失败");
                   }
               })
          }
	/**添加多个文件项**/
	$('#btn-upload-person').click(function(){
		var flag=0;
		var id =0;
		var array = $(("input[type='checkbox']"));
		for(var i=0;i<array.length;i++){
		  console.info(array[i].id);
		  if($('#'+array[i].id).is(':checked')){
			var id = array[i].id;
		      flag++;
		      if(flag>1){
		    	  alert("对不起，只能选择单行");
		    	return false;
		      }else{
		    	  id=array[i].id;
		      }
		
		  }
	   
		}
		  if(flag==1){
			  $('#personName1').val("");
			  $('#uploadFile1').val("");
			  $('#personName2').val("");
			  $('#uploadFile2').val("");
			  $('#personName3').val("");
			  $('#uploadFile3').val("");
			  $('#personName4').val("");
			  $('#uploadFile4').val("");
			  $('#personName5').val("");
			  $('#uploadFile5').val("");
			  
			  $('#personPicturesModal').modal('show');
			  $('#idPersonFile')[0].value=id;
			 
		     }
		
	});
	
	$('#btn-save-person-picture').click(function(){
		var id = $('#idPersonFile')[0].value;
		//获取主演信息的名称
		var personName1 = $('#personName1')[0].value;
		var personName2 = $('#personName2')[0].value;
		var personName3 = $('#personName3')[0].value;
		var personName4 = $('#personName4')[0].value;
		var personName5 = $('#personName5')[0].value;
	/*	uploadPersonPicture(id);*/
	
	
	/*function uploadPersonPicture(id,personName1,personName2,personName3,personName4,personName5){*/
		   $.ajaxFileUpload({
            url: '/movie.front/movieInfo/uploadMoviePersonById', //用于文件上传的服务器端请求地址
            type: 'post',
            data:{personName1:personName1,id:id,personName2:personName2,personName3:personName3,personName4:personName4,personName5:personName5}, //此参数非常严谨，写错一个引号都不行，用于传递其他的参数
            secureuri: false, //一般设置为false
            fileElementId: ['uploadFile1','uploadFile2','uploadFile3','uploadFile4','uploadFile5'], //文件上传空间的id属性  <input type="file" id="file" name="file" />
            dataType: 'JSON',//返回值类型 一般设置为json
            success: function (data,status){  //服务器成功响应处理函数
         	   if(status=='success'){
                    data = jQuery.parseJSON(jQuery(data).text());
         		   if(data.successcode>0){
         			   alert("上传成功");
         			   $('#personPicturesModal').modal('hide');
         			  selectAllMovieInfo(1);
         		   }else{
         			   alert("上传失败");
         		   }
         	   }
      
            },
            error: function (data)//服务器响应失败处理函数
            {
                alert("网络连接失败");
            }
        });
	/*}*/
	})
	
	$('#btn-upload-video').click(function(){
		var flag=0;
		var id =0;
		var array = $(("input[type='checkbox']"));
		for(var i=0;i<array.length;i++){
		  console.info(array[i].id);
		  if($('#'+array[i].id).is(':checked')){
			var id = array[i].id;
		      flag++;
		      if(flag>1){
		    	  alert("对不起，只能选择单行");
		    	return false;
		      }else{
		    	  id=array[i].id;
		      }
		  }
		}
		  if(flag==1){
			  $('#uploadFileVideo').val("");
			  $('#myVideoModal').modal('show');
			  $('#idVideoFile')[0].value=id;
			
		     }
	});
	$('#btn-save-viewo').click(function(){
     var id = $('#idVideoFile')[0].value;
		
		uploadMovieVideo(id);
	});
	
	function uploadMovieVideo(id){
		   $.ajaxFileUpload({
               url: '/movie.front/movieInfo/uploadVideoById', //用于文件上传的服务器端请求地址
               type: 'post',
               data:{id:id}, //此参数非常严谨，写错一个引号都不行
               secureuri: false, //一般设置为false
               fileElementId: 'uploadFileVideo', //文件上传空间的id属性  <input type="file" id="file" name="file" />
               dataType: 'JSON',//返回值类型 一般设置为json
               success: function (data,status){  //服务器成功响应处理函数
            	   if(status=='success'){
                       data = jQuery.parseJSON(jQuery(data).text());
            		   if(data.successcode>0){
            			   alert("上传成功");
            			   $('#myVideoModal').modal('hide');
            				selectAllMovieInfo(1);
            		   }else{
            			   alert("上传失败");
            		   }
            	   }
         
               },
               error: function (data)//服务器响应失败处理函数
               {
                   alert("网络连接失败");
               }
           })
		
	}
 });

//当前页
function currentPagesquery(currentId){
	 // alert(currentId);当前页码
	  $('#paginator').empty();
	     var p ={};
         p.pageSize = 6;
         p.pageNum = currentId;
         $('#movie-table').empty();
		  $('#movie-table').append('<tr><td></td><td  hidden="true">主键号</td> <td>序号</td><td>电影名称</td><td>上映时间</td><td>价格(元)</td><td>是否热门</td><td>是否预售期</td><td>影厅</td><td>影片</td></tr>');
    $.ajax({
	  type:"POST",
	  url:"/movie.front/movieInfo/getSysAllMovieInfoList",
	  data:JSON.stringify(p),
	  dataType:"json",
	  contentType:"application/json",
	  success:function(data){
		     array =  data.result.list;
	           var url='http://localhost:8080/';
	           if(currentId==1){
	           for(var i=0;i<array.length;i++){
	        	   var html = '' ;
	        	   var movieTime = transfer(array[i].movieTime);
	        	   var moviePicture = array[i].moviePicture;
	        	   if(moviePicture==""||moviePicture==undefined){
	        		   if(array[i].isHot==1){
	             		
	             		  html = html+'<tr><td><input type="checkbox" id="'+array[i].id+'"></td><td  hidden="true">'+array[i].id+'</td><td>'+(i+1)+'</td><td>'+array[i].movieName+'</td><td>'+movieTime+'</td><td>'+array[i].moviePrice+'</td><td>是</td><td>'+ array[i].isSell+'</td><td>'+array[i].hallName+'</td><td></td></tr>';  
	        		   }else{
	             		  html = html+'<tr><td><input type="checkbox" id="'+array[i].id+'"></td><td  hidden="true">'+array[i].id+'</td><td>'+(i+1)+'</td><td>'+array[i].movieName+'</td><td>'+movieTime+'</td><td>'+array[i].moviePrice+'</td><td>否</td><td>'+ array[i].isSell+'</td><td>'+array[i].hallName+'</td><td></td></tr>';  
	             	  }
	        	   }else{
	        	      if(array[i].isHot==1){
	        		  html = html+'<tr><td><input type="checkbox" id="'+array[i].id+'"></td><td  hidden="true">'+array[i].id+'</td><td>'+(i+1)+'</td><td>'+array[i].movieName+'</td><td>'+movieTime+'</td><td>'+array[i].moviePrice+'</td><td>是</td><td>'+array[i].isSell+'</td><td>'+ array[i].hallName+'</td><td><img style="width:60px;height:80px" src='+url+array[i].moviePicture+'></td></tr>';  
	        	     }else{
	        		  html = html+'<tr><td><input type="checkbox" id="'+array[i].id+'"></td><td  hidden="true">'+array[i].id+'</td><td>'+(i+1)+'</td><td>'+array[i].movieName+'</td><td>'+movieTime+'</td><td>'+array[i].moviePrice+'</td><td>否</td><td>'+array[i].isSell+'</td><td>'+array[i].hallName+'</td><td><img style="width:60px;height:80px" src='+url+array[i].moviePicture+'></td></tr>';
	        	     }
	        	   }
	           	    $('#movie-table').append(html); 
	           }
	          }else{
	        	  for(var i=0;i<array.length;i++){
		        	   var html = '' ;
		        	   var movieTime = transfer(array[i].movieTime);
		        	   var moviePicture = array[i].moviePicture;
		        	   var flag = (currentId-1)*6+i+1;
		        	   if(moviePicture==""||moviePicture==undefined){
		        		   if(array[i].isHot==1){
		             		  html = html+'<tr><td><input type="checkbox" id="'+array[i].id+'"></td><td  hidden="true">'+array[i].id+'</td><td>'+flag+'</td><td>'+array[i].movieName+'</td><td>'+movieTime+'</td><td>'+array[i].moviePrice+'</td><td>是</td><td>'+array[i].isSell+'</td><td>'+array[i].hallName+'</td><td></td></tr>';  
		             	  }else{
		             		  html = html+'<tr><td><input type="checkbox" id="'+array[i].id+'"></td><td  hidden="true">'+array[i].id+'</td><td>'+flag+'</td><td>'+array[i].movieName+'</td><td>'+movieTime+'</td><td>'+array[i].moviePrice+'</td><td>否</td><td>'+array[i].isSell+'</td><td>'+array[i].hallName+'</td><td></td></tr>';
		             	  }
		        	   }else{
		        	      if(array[i].isHot==1){
		        		  html = html+'<tr><td><input type="checkbox" id="'+array[i].id+'"></td><td  hidden="true">'+array[i].id+'</td><td>'+flag+'</td><td>'+array[i].movieName+'</td><td>'+movieTime+'</td><td>'+array[i].moviePrice+'</td><td>是</td><td>'+array[i].isSell+'</td><td>'+array[i].hallName+'</td><td><img style="width:60px;height:80px" src='+url+array[i].moviePicture+'></td></tr>';  
		        	     }else{
		        		  html = html+'<tr><td><input type="checkbox" id="'+array[i].id+'"></td><td  hidden="true">'+array[i].id+'</td><td>'+flag+'</td><td>'+array[i].movieName+'</td><td>'+movieTime+'</td><td>'+array[i].moviePrice+'</td><td>否</td><td>'+array[i].isSell+'</td><td>'+array[i].hallName+'</td><td><img style="width:60px;height:80px" src='+url+array[i].moviePicture+'></td></tr>';
		        	     }
		        	   }
		           	    $('#movie-table').append(html); 
		           }  
	          }
	           
	           $('#paginator').empty();
	           var totalPages = data.result.pages;
	        	   var pageHtml = '<ul>';
	        	   pageHtml =pageHtml+'<li class="m-pagination-page"><a herf="javascript:void(0);" id="firstPage" onclick="firstPagesquery(1)"> 首页 </a></li>';
	        	   for(var i=0;i<totalPages;i++){
	        		  pageHtml = pageHtml+'<li class="m-pagination-page"><a herf="javascript:void(0);" onclick="currentPagesquery('+(i+1)+')" id='+(i+1)+'>'+(i+1)+'</a></li>'; 
	        	   }
	        	   pageHtml =pageHtml+'<li class="m-pagination-page"><a herf="javascript:void(0);" id="endPage" onclick="endPagequery('+totalPages+')">尾页</a></li>';
	        	   pageHtml =pageHtml+'</ul>';
	        	   $('#paginator').append(pageHtml);
	  }

  });
}

//首页
function  firstPagesquery(firstPageId){
	currentPagesquery(firstPageId);
}

//尾页
function  endPagequery(endPageId){
	currentPagesquery(endPageId);
	 }

function transfer(val){
	if(val){
		val = parseInt(val, 10) * 1000;
		var date = new Date(val);
		//return date.format('yyyy-MM-dd hh:mm:ss');
		return date.format('yyyy-MM-dd hh:mm:00');
	}
	return '';
}
//重写javaScript日期对象原型
Date.prototype.format = function(fmt){
	var o = {
		'M+': this.getMonth() + 1,//月份
		'd+': this.getDate(),//日
		'h+': this.getHours(),//小时
		'm+': this.getMinutes(),//分
		's+': this.getSeconds(),//秒
		'q+': Math.floor((this.getMonth() + 3) / 3),//季度
		'S': this.getMilliseconds()//毫秒
	};
	if(/(y+)/.test(fmt))
		fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length));
	for( var k in o)
		if(new RegExp('(' + k + ')').test(fmt))
			fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)));
	return fmt;
}
 function currentPagesqueryParam(currentId,p){
	 alert("aaaa");
/*	  $('#paginator').empty();
	   
      p.pageSize = 6;
      p.pageNum = currentId;
      $('#movie-table').empty();
		  $('#movie-table').append('<tr><td></td><td  hidden="true">主键号</td> <td>序号</td><td>电影名称</td><td>上映时间</td><td>价格(元)</td><td>是否热门</td><td>是否预售期</td><td>影厅</td><td>影片</td></tr>');
 $.ajax({
	  type:"POST",
	  url:"/movie.front/movieInfo/getSysAllMovieInfoList",
	  data:JSON.stringify(p),
	  dataType:"json",
	  contentType:"application/json",
	  success:function(data){
		     array =  data.result.list;
	           var url='http://localhost:8080/';
	           if(currentId==1){
	           for(var i=0;i<array.length;i++){
	        	   var html = '' ;
	        	   var movieTime = transfer(array[i].movieTime);
	        	   var moviePicture = array[i].moviePicture;
	        	   if(moviePicture==""||moviePicture==undefined){
	        		   if(array[i].isHot==1){
	             		
	             		  html = html+'<tr><td><input type="checkbox" id="'+array[i].id+'"></td><td  hidden="true">'+array[i].id+'</td><td>'+(i+1)+'</td><td>'+array[i].movieName+'</td><td>'+movieTime+'</td><td>'+array[i].moviePrice+'</td><td>是</td><td>'+ array[i].isSell+'</td><td>'+array[i].hallName+'</td><td></td></tr>';  
	        		   }else{
	             		  html = html+'<tr><td><input type="checkbox" id="'+array[i].id+'"></td><td  hidden="true">'+array[i].id+'</td><td>'+(i+1)+'</td><td>'+array[i].movieName+'</td><td>'+movieTime+'</td><td>'+array[i].moviePrice+'</td><td>否</td><td>'+ array[i].isSell+'</td><td>'+array[i].hallName+'</td><td></td></tr>';  
	             	  }
	        	   }else{
	        	      if(array[i].isHot==1){
	        		  html = html+'<tr><td><input type="checkbox" id="'+array[i].id+'"></td><td  hidden="true">'+array[i].id+'</td><td>'+(i+1)+'</td><td>'+array[i].movieName+'</td><td>'+movieTime+'</td><td>'+array[i].moviePrice+'</td><td>是</td><td>'+array[i].isSell+'</td><td>'+ array[i].hallName+'</td><td><img style="width:60px;height:80px" src='+url+array[i].moviePicture+'></td></tr>';  
	        	     }else{
	        		  html = html+'<tr><td><input type="checkbox" id="'+array[i].id+'"></td><td  hidden="true">'+array[i].id+'</td><td>'+(i+1)+'</td><td>'+array[i].movieName+'</td><td>'+movieTime+'</td><td>'+array[i].moviePrice+'</td><td>否</td><td>'+array[i].isSell+'</td><td>'+array[i].hallName+'</td><td><img style="width:60px;height:80px" src='+url+array[i].moviePicture+'></td></tr>';
	        	     }
	        	   }
	           	    $('#movie-table').append(html); 
	           }
	          }else{
	        	  for(var i=0;i<array.length;i++){
		        	   var html = '' ;
		        	   var movieTime = transfer(array[i].movieTime);
		        	   var moviePicture = array[i].moviePicture;
		        	   var flag = (currentId-1)*6+i+1;
		        	   if(moviePicture==""||moviePicture==undefined){
		        		   if(array[i].isHot==1){
		             		  html = html+'<tr><td><input type="checkbox" id="'+array[i].id+'"></td><td  hidden="true">'+array[i].id+'</td><td>'+flag+'</td><td>'+array[i].movieName+'</td><td>'+movieTime+'</td><td>'+array[i].moviePrice+'</td><td>是</td><td>'+array[i].isSell+'</td><td>'+array[i].hallName+'</td><td></td></tr>';  
		             	  }else{
		             		  html = html+'<tr><td><input type="checkbox" id="'+array[i].id+'"></td><td  hidden="true">'+array[i].id+'</td><td>'+flag+'</td><td>'+array[i].movieName+'</td><td>'+movieTime+'</td><td>'+array[i].moviePrice+'</td><td>否</td><td>'+array[i].isSell+'</td><td>'+array[i].hallName+'</td><td></td></tr>';
		             	  }
		        	   }else{
		        	      if(array[i].isHot==1){
		        		  html = html+'<tr><td><input type="checkbox" id="'+array[i].id+'"></td><td  hidden="true">'+array[i].id+'</td><td>'+flag+'</td><td>'+array[i].movieName+'</td><td>'+movieTime+'</td><td>'+array[i].moviePrice+'</td><td>是</td><td>'+array[i].isSell+'</td><td>'+array[i].hallName+'</td><td><img style="width:60px;height:80px" src='+url+array[i].moviePicture+'></td></tr>';  
		        	     }else{
		        		  html = html+'<tr><td><input type="checkbox" id="'+array[i].id+'"></td><td  hidden="true">'+array[i].id+'</td><td>'+flag+'</td><td>'+array[i].movieName+'</td><td>'+movieTime+'</td><td>'+array[i].moviePrice+'</td><td>否</td><td>'+array[i].isSell+'</td><td>'+array[i].hallName+'</td><td><img style="width:60px;height:80px" src='+url+array[i].moviePicture+'></td></tr>';
		        	     }
		        	   }
		           	    $('#movie-table').append(html); 
		           }  
	          }
	           
	           $('#paginator').empty();
	           var totalPages = data.result.pages;
	        	   var pageHtml = '<ul>';
	        	   pageHtml =pageHtml+'<li class="m-pagination-page"><a herf="javascript:void(0);" id="firstPage" onclick="firstPagesquery(1)"> 首页 </a></li>';
	        	   for(var i=0;i<totalPages;i++){
	        		  pageHtml = pageHtml+'<li class="m-pagination-page"><a herf="javascript:void(0);" onclick="currentPagesquery('+(i+1)+')" id='+(i+1)+'>'+(i+1)+'</a></li>'; 
	        	   }
	        	   pageHtml =pageHtml+'<li class="m-pagination-page"><a herf="javascript:void(0);" id="endPage" onclick="endPagequery('+totalPages+')">尾页</a></li>';
	        	   pageHtml =pageHtml+'</ul>';
	        	   $('#paginator').append(pageHtml);
	  }

});*/
	 
 }
